<?php
/**
 * Wrapper class for database functions
 *
 */
class DBO
{
	private static $instance;
	private function __construct(){}
	public static function getInstance(){
		if(self::$instance === null){
			self::$instance = new DBO(); 
		}
		return self::$instance;
	}
	function query(){
		$argv = func_get_args();
		return call_user_func_array('db_query',$argv);
	}

	function fetchArray(){
		$argv = func_get_args();
		$res = call_user_method_array('query',$this,$argv);
		$ret = array();
		while($row = db_fetch_array($res)){
			$ret[] = $row;
		}
		return $ret;
	}
	function lastInsertId(){
		$res = $this->fetchArray("SELECT LAST_INSERT_ID() as id");
		return $res[0]['id'];
	}
	function getMetaColumns($table){
		return $this->fetchArray("SHOW columns FROM {{$table}}");
	}
}
?>
